﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using CapstoneProjectAEReader.Business.Others;
using DotNetOpenAuth.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using Google.Apis.Drive.v2;
using Google.Apis.Util;
using CapstoneProjectAEReader.Common.Utility;

namespace CapstoneProjectAEReader.GUIs
{
    /// <summary>
    /// Interaction logic for SyncAuthGUI.xaml
    /// </summary>
    public partial class SyncAuthGUI : Window
    {

        private const string Authen = "authen";
        private const string AuthenError = "authenError";

        private SyncManager _syncManager;
        public SyncAuthGUI(SyncManager syncManager)
        {
            _syncManager = syncManager;
            InitializeComponent();
            ReloadFormLanguage();
        }

        private void ReloadFormLanguage()
        {
            lbAuthen.Content = ResourceReader.GetResourceContent(Authen);
        }

        private void Ok_Button_Click(object sender, RoutedEventArgs e)
        {
            string _authCode = authCode.Text;
            if(string.IsNullOrEmpty(_authCode))
            {
                errorMessage.Content = ResourceReader.GetResourceContent(AuthenError);
            } else
            {
                _syncManager.AuthCode = _authCode;
                Close();
            }
        }

        private void Cancel_Button_Click(object sender, RoutedEventArgs e)
        {
            _syncManager.ContinueCheck = 0;
            Close();
        }
    }
}
